var express = require('express');
var app = express();
var wechat = require('wechat-enterprise');
var wechatconfig ={
        corpId: 'wxbea72108079dcb26',
        corpsecret: 'wbqx1xWAELa3HmdJLqjpOk4FXkWh6UjF_kc4mPlwjz9Hlj8yOf-9u5s9TFzhSSWz',
        token: '1iBZ',
        encodingAESKey: '4JdmSv43zuTE8D8rECS45XTvs1dHc5uyUwaOpKUNyHg',
        access_token:'',
        access_token_time:''
    };

app.get('/', function (req, res) {
  res.send('Hello World!');
});

var reply = "客官来的有点早啊，活动尚未开始哦！";

app.use('/corp', wechat(wechatconfig,
  wechat.text((message, req, res, next) => {
  	console.log(message);
    res.reply(reply);
  })
  .location((message, req, res, next) => {
    res.reply(reply);
  })
  .image((message, req, res, next) => {
     res.reply(reply);
  })
  .video((message, req, res, next) => {
     res.reply(reply);
  })
  .voice((message, req, res, next) => {
     res.reply(reply);
  })
));


var server = app.listen(9090, function () {
  var host = server.address().address;
  var port = server.address().port;

  console.log('Example app listening at http://%s:%s', host, port);
});